﻿var pltsPop = null;
var pltsoffsetX = 10;
// 弹出窗口位于鼠标左侧或者右侧的距离；3-12 合适
var pltsoffsetY = 15;
// 弹出窗口位于鼠标下方的距离；3-12 合适
var pltsPopbg = "#FFFFFF";
//背景色
var pltsPopfg = "#111111";
//前景色
var pltsTitle = "";
document.write('<div id="pltsTipLayer" style="display: none;position: absolute; z-index:10001"></div>');

function pltsinits() {
    document.onmouseover = plts;
    document.onmousemove = moveToMouseLoc;
}

function plts() {
    if (typeof (window.pltsTipLayer) != 'undefined') {
        var o = event.srcElement;
        if (o != null) {
            if (o.alt != null && o.alt != "") {
                o.dypop = o.alt;
                o.alt = "";
            }
            if (o.title != null && o.title != "") {
                o.dypop = o.title;
                o.title = "";
            }
            pltsPop = o.dypop;
            if (pltsPop != null && pltsPop != "" && typeof (pltsPop) != "undefined") {
                window.pltsTipLayer.style.left = -1000;
                window.pltsTipLayer.style.display = '';
                var msg = pltsPop.replace(/\n/g, "<br>");
                msg = msg.replace(/\0x13/g, "<br>");
                var re = /\{(.[^\{]*)\}/ig;
                if (!re.test(msg)) pltsTitle = "<span style='font-size:14px;'>石大路货运信息系统</span>";
                else {
                    re = /\{(.[^\{]*)\}(.*)/ig;
                    pltsTitle = msg.replace(re, "$1") + " ";
                    re = /\{(.[^\{]*)\}/ig;
                    msg = msg.replace(re, "");
                    msg = msg.replace("<br>", "");
                }
                var attr = (document.location.toString().toLowerCase().indexOf("list.asp") > 0 ? "nowrap" : "");
                var content =
                '<table style="FILTER:alpha(opacity=90) shadow(color=#bedae9,direction=135);" id=toolTipTalbe border=0><tr><td width="100%"><table style="background-color: #bedae9;" cellspacing="1" cellpadding="0" style="width:100%">' +
                    '<tr id=pltsPoptop ><th height=18 valign=bottom><b><p id=topleft align=left><font color=#004785>↖</font>' + pltsTitle + '</p><p id=topright align=right style="display:none">' + pltsTitle + '<font color=#004785>↗</font></b></th></tr>' +
                        '<tr><td ' + attr + ' style="color:' + pltsPopfg + ';background-color: ' + pltsPopbg + ';padding:6px 14px 6px 14px;font-size:14px; line-height:135%">' + msg + '</td></tr>' +
                            '<tr id=pltsPopbot style="display:none"><th height=18 valign=bottom><b><p id=botleft align=left><font color=#004785>↙</font>' + pltsTitle + '</p><p id=botright align=right style="display:none">' + pltsTitle + '<font color=#004785>↘</font></b></th></tr>' +
                                '</table></td></tr></table>';
                window.pltsTipLayer.innerHTML = content;
                var iframeWidth = Math.min(window.pltsTipLayer.clientWidth, document.body.clientWidth / 2.2);
                window.toolTipTalbe.style.width = iframeWidth;
                window.pltsTipLayer.innerHTML = '<iframe style="position: absolute; z-index: -1; width: ' + (iframeWidth - 3) + 'px; height: ' + (window.pltsTipLayer.clientHeight - 3) + 'px; top: 3px; left: 3px; scrolling: no;filter=""progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"";" frameborder="0" src=""></iframe>' + window.pltsTipLayer.innerHTML;
                moveToMouseLoc();
                return true;
            } else {
                window.pltsTipLayer.innerHTML = '';
                window.pltsTipLayer.style.display = 'none';
                return true;
            }
        }
    }
    return false;
}

function moveToMouseLoc() {
    if (typeof(window.pltsTipLayer) != 'undefined') {
        if (window.pltsTipLayer.innerHTML == '') return true;

        var mouseX = event.x;
        var mouseY = event.y;
        var topleft = document.getElementById("topleft");
        var botleft = document.getElementById("botleft");
        var topright = document.getElementById("topright");
        var botright = document.getElementById("botright");
        //window.status=event.y;
        var popHeight = window.pltsTipLayer.clientHeight;
        var popWidth = window.pltsTipLayer.clientWidth;
        if (mouseY + pltsoffsetY + popHeight > document.body.clientHeight) {
            window.popTopAdjust = -popHeight - pltsoffsetY * 1.5;
            window.pltsPoptop.style.display = "none";
            window.pltsPopbot.style.display = "";
        } else {
            window.popTopAdjust = 0;
            window.pltsPoptop.style.display = "";
            window.pltsPopbot.style.display = "none";
        }
        if (mouseX + pltsoffsetX + popWidth > document.body.clientWidth) {
            window.popLeftAdjust = -popWidth - pltsoffsetX * 2;
            topleft.style.display = "none";
            botleft.style.display = "none";
            topright.style.display = "";
            botright.style.display = "";
        } else {
            window.popLeftAdjust = 0;
            topleft.style.display = "";
            botleft.style.display = "";
            topright.style.display = "none";
            botright.style.display = "none";
        }

        var scrollPos;
        if (typeof window.pageYOffset != 'undefined') {
            scrollPos = window.pageYOffset;
        } else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
            scrollPos = document.documentElement.scrollTop;
        } else if (typeof document.body != 'undefined') {
            scrollPos = document.body.scrollTop;
        }

        window.pltsTipLayer.style.left = mouseX + pltsoffsetX + document.body.scrollLeft + window.popLeftAdjust;
        window.pltsTipLayer.style.top = mouseY + pltsoffsetY + scrollPos + window.popTopAdjust;
        return true;
    }
    return false;
}

pltsinits();
